Managing and maintaining multiple debug contexts in a debug execution mode for real-time processors

ABSTRACT

A real-time debugger implementation maintains and manages multiple debug contexts allowing developers to interact with real-time applications without “breaking” the system in which the debug application is executing. The debugger allows multiple debug contexts to exist and allows break points in real-time and non-real-time code portions of one or more applications executing on a debug enabled core of a processor. A debug monitor function may be implemented as a hardware logic module on the same integrated circuit as the processor. Higher priority interrupt service requests may be serviced while otherwise maintaining a context for the debug session (e.g., stopped at a developer defined breakpoint). Accordingly, the application developer executing the debugger may not have to be concerned with processing occurring on the processor that may be unrelated to the current debug session.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.15/981,258 filed on May 16, 2018, which is incorporated by referenceherein in its entirety.

BACKGROUND

Embedded processors are widely used in a variety of applications andgenerally include processor circuitry that executes embedded code toperform desired functions. One type of embedded processor is amicrocontroller which can be used, for example, to control the operationof a device or device component, such as a motor. Another type ofembedded processor is a digital signal processor (DSP), which may beused, for example, in a variety of communications products, such ascellular phones. The use of an embedded processor to perform desiredfunctions generally requires the development and debugging of a varietyof concurrently executing applications with some applications takingadvantage of embedded code. In many applications, the embedded codeincludes foreground code for performing time-critical (real-time) tasks,and background code for performing administrative or higher-level(non-real-time) tasks. Debugging of real-time code in any processor,either embedded or general purpose, has similar complications that maybe addressed by concepts of the disclosed implementations. Similarly,application code may be embedded in a control system or provided byother conventional means. Conceptually, it is easier to considerembedded code in an embedded processor for the concepts of thisdisclosure; however, the disclosed issues and improvements are notlimited to just this type of code and processor.

For certain applications, it may be particularly important to be able todebug the embedded code using real-time execution control. It may alsobe important to provide for real-time debug access to internal flags,registers and/or memory. The contents of such flags, registers, andmemory provide the “context” of an embedded processor and the code it isexecuting at any given time. In normal operation, access to processorcontext is provided without using a debug monitor and without stoppingthe processor. Real-time execution control allows for the suspension ofan embedded processor's execution of a given task while still allowingthe processor to continue servicing other time-critical tasks. Thus,real-time execution control may allow the user of processor developmentand debug tools to interactively control the execution of code withinthe system without necessarily interfering with the processor's abilityto perform time-critical tasks. For example, if embedded code is beingdebugged in a processor used to control a hard disk drive motor, theprocessor should not be allowed to stop the real-time threads/tasks thatmaintain the motor's functionality. Otherwise, the motor may go out ofcontrol and destroy the hard disk drive. Thus, it may be important toallow the processor to continue to execute the time-critical task ofcontrolling the motor while the embedded instruction code is beingdebugged. In another example, debugging code within an active controlsystem (e.g., cellular tower) should allow the cellular tower tomaintain its core function (e.g., not drop all active calls) whileallowing an application associated with a subset of connections to beanalyzed (e.g., debugged).

On the other hand, if one or more real-time interrupts occur during apreviously-initiated debug event, the processor context, for example,the operational state of the processor including the values of itsinternal memory and registers, may be subject to changes (e.g., fromother functioning code). These types of changes affect the overallcontext and may provide spurious or misleading information to the debughost and ultimately the application developer performing the analysis.Accordingly, it may be desirable to take steps to ensure coherency ofthe debug context data. That is, the application developer should beable to trust the data retrieved is relative to where the debugbreakpoint has been set, for example. The term “debug host” refers to asystem external to but communicatively coupled to the processor(s)executing the code being executed in debug mode. For example, the debughost refers to a system that provides a user interface for anapplication developer performing the act of debugging. One example of adebug host is an in-circuit debugger (ICD). An ICD is a hardware devicethat connects to the microprocessor, for example via a JTAG or Nexusinterface to allow the operation of the microprocessor to be controlledexternally. JTAG is named after the Joint Test Action Group and iscodified in an industry standard formally referred to as IEEE 1149.1.JTAG specifies the use of a dedicated debug port implementing a serialcommunications interface for low-overhead access without requiringdirect external access to the system address and data buses. Theinterface may connect to an on-chip test access port (TAP) thatimplements a stateful protocol to access a set of test registers thatpresent chip logic levels and device capabilities of various parts.Nexus is a standard formally referred to as IEEE-ISTO 5001-2003,incorporated by reference herein in its entirety. Nexus defines astandard set of connectors for connecting the debug tool to the targetor system under test. Logically, data is transferred using apacket-based protocol. This protocol can be JTAG; or, for high-speedsystems, an auxiliary port can be used that supports full duplex, higherbandwidth transfers.

When a user is debugging an application (or embedded system)request/response interactions, or packets may be transferred to aprocessor in a debug state (e.g., through the debug port). Theseinteractions help control a debug session and may include: A) Run-timecontrol representing that debug tools can start and stop the processor,modify registers, and single-step machine instructions. B) Memory accessrequests both while the processor is running and while it is paused.Access requests of a running processor may be required when debuggingsystems where it is not possible to completely halt the system undertest. Examples include debugging an application in an active cell tower,where stopping digital feedback loops can cause undesired serviceinterruptions. Note, disclosed Polite and Rude request types areintroduced in this disclosure to further address memory access. C)Breakpoints representing that programs halt when a specified event(e.g., program counter has reached a breakpoint) has occurred. The eventmay sometimes be specified as a code execution address, or as a dataaccess (read or write) to an address with a specified value. Whendebugging, several kinds of event tracing may be used. More details maybe found in the above referenced standards which are incorporated byreference herein in their entirety.

Even though there are industry standards defining certain aspects ofprocessor debugging capabilities and communication interfaces, externalcontrol (e.g., control from a debug host system) is typically restrictedto the specific debugging capabilities “built-in” to the processor.Accordingly, more robust debug capabilities built-in to a processor mayenhance the flexibility and usability for application developers toimplement, test, and validate their code. This disclosure presents atleast three examples of such improvements that may be used individuallyor collectively to assist application developers as described. Moreparticularly, but not by way of limitation, this disclosure relates toprocessors having real-time execution control for debug functions toallow a) a real-time execution mode including interrupt handling todebug real-time applications, b) managing multiple real-time debugcontexts, and c) maintaining a coherent debug view duringmulti-dimensional debugging operations. In the following DetailedDescription section, each of these capabilities is independentlysummarized at a high level and then discussed in more detail withreference to the Figures as necessary.

SUMMARY

In a first example implementation, a computing device comprising: aprocessing unit; and a debug controller communicatively coupled to theprocessing unit and including at least one input/output interface,wherein the debug controller contains logic that when executed causesthe debug controller to perform a debug monitor function, the debugmonitor function configured to: recognize a first breakpoint for theprocessing unit in a first code section having a first executionpriority, in part, by pausing the processing unit and establishing afirst debug context; receive an indication that a second code section ofa higher execution priority than the first execution priority requiresservicing while the processing unit is halted at the first breakpoint;allow the processing unit to resume execution to service the second codesection while maintaining the first debug context; and return to anexecution state consistent with the first debug context, in part, bypausing the processing unit in the first code section upon completion ofservicing the second code section. Note, the debug monitor may beimplemented using additional hardware module logic on an integratedcircuit containing the processing unit.

The computing device of this first example may be extended to furtherinclude configuration to: recognize a second breakpoint in the secondcode section at the debug controller; pause execution of the processingunit at the second breakpoint; store information of the first debugcontext on a stack; allow the debug controller to process functions ofthe debug monitor while at the second breakpoint; obtain informationrepresentative of a second debug context at the debug monitor; receivean indication to continue execution of the processing unit from thesecond breakpoint; pause execution of the processing unit upon returnfrom the second code section to the first code section; and returncontrol to the debug controller executing the debug monitor in the firstdebug context for the first code section.

In a second example implementation a method of debugging program codeexecuting on a processor configured with a debug controller performing adebug monitor function, the program code including a plurality of codesections, each code section associated with an execution priority level,the method including: executing a first code section having a firstexecution priority on the processor while allowing interrupting codesections of a higher execution priority than the first executionpriority to pre-empt execution of the first code section for a period ofexecution to complete each interrupting code section; recognizing afirst breakpoint in the first code section at the debug controller;pausing execution of the processor at the first breakpoint; allowing thedebug controller to process functions of the debug monitor while at thefirst breakpoint; obtaining information representative of a first debugcontext at the debug monitor, the first debug context associated withregister values attributable to the first code section at the firstbreakpoint; receiving an indication that a second code section, of ahigher execution priority than the first execution priority, attempts topre-empt execution of the first code section while at the firstbreakpoint of the first code section; allowing the processor to executefor a period of execution to complete the second code section whilemaintaining the first debug context of the debug monitor associated withthe first breakpoint of the first code section; and returning control tothe debug controller executing the debug monitor in the first debugcontext upon completion of the second code section.

BRIEF DESCRIPTION OF THE DRAWINGS

For a detailed description of various examples, reference will now bemade to the accompanying drawings, in which:

FIG. 1 illustrates a processor state diagram representing one possibleexample of an application having both non-real-time and real-timeelements;

FIG. 2 illustrates a block diagram of a debug environment 200, includinga user 215 (e.g., application developer performing debugging), a debughost 205, and a debug controller 255 (e.g., configured to execute debugmonitor 256) in which different examples of this disclosure may beadvantageously applied;

FIG. 3 illustrates a processor state diagram representing one possibleexample for real-time mode debugging of a system;

FIG. 4a illustrates a state diagram and FIG. 4b illustrates a programflow diagram depicting processor operation associated with debug andreal-time interrupt events for an example program flow within a possibledebug session on a processor configured with real-time debugcapabilities, according to one or more disclosed examples;

FIG. 5a illustrates a state diagram (500) and FIG. 5b illustrates aprogram flow diagram (502) depicting processor operation associated withdebug and real-time interrupt events for a second example program flowwithin a possible debug session operating on a processor configured withreal-time debug capabilities, according to one or more disclosedexamples;

FIG. 6 illustrates a timing diagram of an example of possible logicsignals that may be present in a processing system configured to handledebug and real-time interrupt events in accordance with one or moredisclosed examples;

FIG. 7 illustrates a flowchart depicting an example flow, from theperspective of the user, of interacting with a processor equipped withcapabilities in accordance with one or more disclosed examples; and

FIG. 8 illustrates a general purpose processor, shown without allpossible elements of this disclosure, including a debug controller and adebug monitor in accordance with one or more disclosed exampleimplementations.

DETAILED DESCRIPTION

In the following description, for purposes of explanation, numerousspecific details are set forth in order to provide a thoroughunderstanding of the examples disclosed herein. It will be apparent,however, to one skilled in the art that the disclosed exampleimplementations may be practiced without these specific details. Inother instances, structure and devices are shown in block diagram formin order to avoid obscuring the disclosed examples. Moreover, thelanguage used in this disclosure has been principally selected forreadability and instructional purposes, and may not have been selectedto delineate or circumscribe the inventive subject matter, resorting tothe claims being necessary to determine such inventive subject matter.Reference in the specification to “one example” or to “an example” meansthat a particular feature, structure, or characteristic described inconnection with the examples is included in at least one implementation.

The term “computing system” is generally taken to refer to at least oneelectronic computing device that includes, but is not limited to, asingle computer, virtual machine, virtual container, host, server,laptop, and/or mobile device or to a plurality of electronic computingdevices working together to perform the function described as beingperformed on or by the computing system.

As used herein, the term “medium” refers to one or more non-transitoryphysical media that together store the contents described as beingstored thereon. Examples may include non-volatile secondary storage,read-only memory (ROM), and/or random-access memory (RAM).

As used herein, the terms “application” and “function” refer to one ormore computing modules, programs, processes, workloads, threads and/or aset of computing instructions executed by a computing system. Exampleimplementations of applications and functions include software modules,software objects, software instances and/or other types of executablecode.

As used herein, the term “embedded” refers to processors and code thatis “built-in” to a device in order to control that device. Embeddedprocessors may be contrasted with general-purpose processors that arenot expected to perform a particular function. Embedded code may bereal-time or non-real-time but is generally intended to be tightlycoupled with a particular embedded processor.

Debugging computer applications may be complicated and several toolsexist to assist the developer in that effort. Application programs thatexecute independently from each other (and from internal operatingsystem operations) may be “stepped through” with a source code leveldebugger. The source code level debugger may pause the high levelapplication without affecting other operations taking place on thecomputer system. In contrast, debugging of lower level and “real-time”applications that interact directly with hardware or have a directinterface to input/output ports is likely more complicated. This is, atleast in part, because low level and real-time applications may not bepaused without having a direct and possibly adverse effect on theprocess they are controlling or possibly other processes concurrentlyexecuting on the same computer system. For the purposes of real-timeprocessor debugging, one simple execution control technique is to stopall processor execution upon a debug halt or break event and not allowfor any interrupts to be processed until execution resumes. Thisapproach is taken in stop mode emulation schemes used in someprocessors. However, this does not allow for controlling the processor'sexecution in a real-time or embedded system.

Another method is to have a break event trigger a special interruptwhich causes the processor to execute an interrupt service routine (ISR)in which the processor waits for either a command to resume execution orfor an enabled time-critical interrupt to occur. This type of interruptservice routine is referred to as a “debug monitor.” A debug monitor is(typically) implemented by code executed by the embedded processor afterbeing placed in a debug state. In this disclosure, implementations of adebug monitor may include hardware logic as opposed to traditionalsoftware based debug monitors. A debug monitor may be configured toexecute on a main processor or an auxiliary processor (“debugcontroller”) that is communicatively coupled to the main processor aswell as memory, registers, input/output ports, and other capabilities ofthe integrated circuit (IC) containing both the main processor and thedebug controller. The debug monitor approach provides a form ofexecution control and is used in some processors in addition to the useof stop mode emulations schemes. The debug monitor (and debugcontroller) should not be confused with a debug host that is external tothe system under test to provide a user interface to the debug session.In short, the debug host typically interfaces with the debug monitorexecuting on the processor, the debug controller, or a combination ofboth.

In a debug monitor approach, ISRs associated with the debug monitor maybe configured to provide communication with the processor, the debugcontroller, the debug host, and ultimately the application developer bystaging information in one or more registers that may be scanned. Inthis implementation technique, the debug controller may scan in commandsand scan out results. When halted, the processor may be configured toexecute the debug monitor internal to the processor (e.g., on a debugcontroller auxiliary processor or the main processor to the exclusion ofother tasks). The debug controller, in turn, typically executesinterrupt service routines (ISRs) while performing commands. Because thedebug controller is internal to the processor (e.g., built-in or tightlycoupled to the processor), the debug monitor scheme must occupy on-chipsystem resources such as program and data memory. In general, on-chipmemory is very expensive and care should be taken to ensure that othersystem resources are not corrupted by execution of the debug monitor.Further, performance overhead due to saving and restoring context may beexperienced as the debug monitor is entered and exited. In most priorart systems, interrupts (and their ISRs), even if they aretime-critical, generally have to be blocked during this “halt for debug”time period.

This disclosure relates to a debug monitor approach that addresses theabove issues and provides an improvement to the technical art ofdebugging. In particular, this disclosure describes an approach thatintegrates functions closely with the processor via a tightly coupleddebug monitor (e.g., hardware logic as part of the debug controller)that provides functionality different from previous debug monitors. Forexample, when debugging a task running in a high level OS, only the taskis halted for inspection/interaction, but the processing engine (e.g., aCPU) continues to execute all lower level (e.g., higher priority)functions. Also, when debugging a low-level embedded system, the debughalt event will freeze the CPU execution pipeline, stopping all codeexecution except that RT tasks (usually of a very high priority) may bekept “alive” even when the processor (e.g., CPU) hardware is halted.That is, any task that is of a higher priority than the halted contextmay be allowed continue to execute at the time it is requested toexecute.

Traditional functionality of a debug monitor is typically implemented insoftware, however, as explained further below, the disclosed debugmonitor may be implemented as a hardware system that controls theprocessor (e.g., CPU) when debugging. Thus, the disclosed debug monitormay represent an additional hardware module implemented on the sameintegrated circuit (IC) and the processor that the debug monitorcontrols. Conceptually, some implementations may consider the debugmonitor a CPU pipeline control mechanism. Of course, the disclosed debugmonitor may also be implemented as a combination of hardware andsoftware where functions necessary to control the CPU pipeline directlymay be implemented in hardware and other capabilities may be implementedin a combination of hardware and software.

Referring to the example of FIG. 1, there is shown a state-machinerepresentation 100 of an application with both non-real-time andreal-time elements. In FIG. 1, a TIMER1 state 105 and a DMA state 110represent separate real-time sections of code that must be serviced inorder to satisfy real-time deadlines. A MAIN state 115 and a TIMER0state 120 represent non-real-time sections of code. A DEBUG state 125represents the suspension of code execution in response to a debugevent, such as a software breakpoint.

In the example of FIG. 1, interrupts are represented with solid-linearrows and may be used to change application context. Halt debug eventsare represented with dashed-line arrows and may be used to suspend codeexecution for debug. Finally, resume debug events are represented withdotted-line arrows and may be used to resume code execution after it hadbeen previously suspended.

With continued reference to FIG. 1, one consequence of not allowingreal-time sections to execute while other sections of code are beingdebugged may include the missing of real-time deadlines. Missed eventsand their associated processing may ultimately result in a corruptedsystem (or worse). One approach that has been taken to solve thisproblem is the use of software monitors (not to be confused with thesoftware/firmware of the disclosed debug monitor) that manage theexecution of code around debug events. In the case of a monitorimplementation, the CPU never stops executing code; the software monitoreffectively manages the execution of code around a debug event. Thissoftware monitor approach has certain potential disadvantages thatinclude, but are not limited to: a) the overhead associated withdevelopment, b) deployment, and maintenance of such a software monitor,c) the inability of such a software monitor to utilize the entirespectrum of debug capabilities, e.g., debugger-initiated real-time CPUregister and memory accesses, and d) the necessity of a communicationlink between the debug controller and a software monitor, possibly aseparate communication link from a typical JTAG link.

Some environments, in particular real-time systems, may have the addedcomplexity of multiple debug contexts. For example, when debugging areal-time system, real-time sections of an application should be allowedto execute while code execution is halted in a non-real-time section. Inaddition, it is possible for a breakpoint to halt code execution of areal-time section after first halting in a non-real-time section. Infact, setting breakpoints across different non-real-time and real-timeapplication sections can result in halting in a non-real-time sectionand a plurality of real-time sections. In general, this may be thoughtof as interrupt driven processing, where higher priority interrupts takeprecedence over the breakpoint of the “lower priority” code.

To support the concept of multiple debug contexts in real-timedebugging, one approach is to provide support for read-access of memoryand registers (relative to one of the potentially multiple debugcontexts) without requiring the processor to completely halt codeexecution. Allowing such memory and register accesses to be servicedagainst a particular debug context helps to maintain a debug sessionthat is consistent and comprehensive. For example, the debug sessionprovides information to a user that is “guaranteed” appropriate for anassociated debug context. Of course, this guarantee may be subject topotential user-overrides as discussed below (e.g., a “rude” request). Inthis case, the term “debugger” is used to generally refer to the debugmonitor, the debug host, and loosely to the application developerinteracting with the debug session.

As should be apparent, debugging includes collecting and presentinginformation (e.g., in response to application developer requests). Forthis reason, the general term “debugger” may represent differententities supporting the act of debugging. For example, a debugger mayrefer to a human being issuing a command at a debug host that is reactedto by a debug monitor that may be executing on a debug controller.Alternatively, a debugger may refer to the collective components of adebug system and which component (or components) performs the actualsteps to perform an action may be determined by the context and usage ofthe term “debugger.”

In a debugging session having many possible debug contexts, support maybe provided for designating interrupts at different levels of priority.As a result, interrupts occurring that are at a “higher priority” thancode relative to a current breakpoint (e.g., place where processor ishalted for debug) may be serviced (e.g., by executing their ISR). Inthis manner, the processor may be able to determine for certain casesthat an interrupt needs to be serviced immediately, even if theprocessor was halted due to a debug event (e.g., in a lower prioritycode section). Servicing of the higher priority interrupt may, in fact,take place without the application developer running the debug sessionbeing aware that it is serviced. Support is also preferably provided forsubmitting execution control requests (e.g., run, step, and halt,requests at the direction of the application developer (or debugger))against a particular debug context. In most implementations, real-timeevents (e.g., interrupts) are given higher priority than allnon-real-time code sections.

One such approach to support multiple debug context involves a debugframe counter (DFC) and a debug frame register (DFR). The mechanism bywhich an interrupt is identified as being real-time or non-real-time canbe influenced by the interrupt architecture. Such mechanisms can includeone or more enable flags for each interrupt request (IRQ), or athreshold level defining the IRQ priority. In this approach, the DFCtracks the current debug context that the processor is operating in. Inone implementation, the DFC decreases its count whenever the processorreturns to a previous debug context after completing execution of areal-time interrupt, and increases its count when entering a new debugcontext by taking a real-time interrupt when previously halted. The DFCis unambiguously communicated to the debugger when the debug state ofthe processor is retrieved.

In this DFR/DFC real-time debug scenario, the debugger (e.g., debug hostinput provided to the debug monitor) will submit requests against aparticular debug context by associating that request with a DFR thatmatches the DFC value that it retrieved with the debug state of theprocessor.

U.S. Pat. No. 6,324,684 to Matt et al., entitled, “Processor HavingReal-Time Execution Control for Debug Functions Without a DebugMonitor,” (“'684 patent”), represents one example of an approachemploying a DFC and a DFR. The '684 patent proposes an execution runstate machine (RSM) that supports real-time mode using a DFC. In the'684 patent, the RSM distinguishes between voluntary execution in“foreground” (i.e., real-time) code and voluntary execution in“background” (i.e., non-real-time) code.

Another approach utilizing a DFC and a DFR is described in U.S. Pat. No.6,564,339 to Swoboda et al., entitled, “Emulation Suspension ModeHandling Multiple Stops and Starts,” (“'339 patent”). The '339 patentproposes the use of a DFR as a means of ensuring a particular debugcontext when the processor services memory, register, and executioncontrol requests submitted to it by a debugger.

Yet another approach utilizing a DFC and a DFR is described in U.S. Pat.No. 6,557,116 to Swoboda et al., entitled, “Emulation Suspension ModeWith Frame Controlled Resource Access,” (“'116” patent). Like the '339patent, the '116 patent proposes the use of a DFR as a means of ensuringa particular debug context when the processor services memory, register,and execution control requests that are submitted to it by a debugger.

The above-referenced '684, '339, and '116 patents are commonly assignedto the assignee of the present application and are each herebyincorporated by reference herein in their respective entireties.

Some perceived or potential disadvantages to the prior art approaches,such as proposed in the '684, '339, and '116 patents, include theiroverall complexity, hardware cost, and failure to account for certainfactors relating to the operating system (OS) context (e.g., identity ofactive virtual machine, kernel versus user code). With regard to theissue of undue complexity, there may be limited advantage indistinguishing whether interrupt (debug halt) events occur duringreal-time or non-real time processing. The use of a debug frame counterto track the current debug context may introduce an added level ofcomplexity that may be overcome in disclosed example implementations. Inparticular, a debugger session may not benefit from tracking and beingaware of how many contexts are below it, but instead need only be awarewhen the debug context changes due to the processor being halted in anew context (e.g., a change in breakpoint).

To address issues with the specific conventional implementationsdiscussed above and to provide alternative improvements to a debugmonitor portion of a real-time processor, this disclosure providesexample implementations that include at least three characteristics.Firstly, a real-time execution mode is disclosed that includes interrupthandling to debug real-time applications. Secondly, the disclosed debugmonitor, in some implementations, provides a debug environmentimplemented as a CPU pipeline control hardware module capable ofmanaging multiple real-time debug contexts. Thirdly, the disclosed debugmonitor may also provide a debug environment that is also capable ofmaintaining a coherent debug view during multi-dimensional debuggingoperations (e.g., handle multiple debug contexts within a single debugsession). Any combination of these, and possibly other, improvements maybe made available as required for an implementation of a real-timeprocessor according to the concepts of this disclosure.

Real-Time Execution Mode

Real-time mode debugging (“RM debug”), in one example, allows a subsetof the normal interrupts of a processor to be designated as “Real-Time”(“RT”) interrupts. Interrupts designated as RT can be serviced tocompletion even when the processor is halted for debug.

Referring to FIG. 2, block diagram illustrates one example of a debugenvironment 200 that may be established in accordance with the conceptsof this disclosure. Debug environment 200 includes a debug host 205, anda target system 210. Target system 210 further includes a processor 230,debug controller 255, and debug monitor 256. In this example, debugmonitor 256 refers to code executing on debug controller 255 to assistin controlling a debug session for code executing on target system 210.This debug session may be interactive with user 215 for example. In thisexample, debug monitor 256 is shown as executing on debug controller255. However, it is possible that in some implementations portions ofdebug monitor 256 may execute on processor 230 and coordinate with otherportions of debug monitor 256 executing on debug controller 255.

In accordance with a conventional user-interface arrangement, a user 215may interact with debug host 205 via a user interface as illustrated bycommunication link 220. In some cases, in addition to “indirect”interaction with target system 210 using debug host 205, a user mayinteract directly (e.g., via an input/output interface) with targetsystem 210 as illustrated by bi-directional arrow 225. Directinteraction may include physically changing settings on target system210 via direct adjustment of controls (not shown) on target system 210or by creating a hardware interrupt to cause a breakpoint for debuggingat a certain time as opposed to, or in addition to, programming in asoftware determined breakpoint.

In this example, processor 230 may be, for example, an embeddedprocessor or multi-core processor that exchanges control and otheroperational signals with a controlled device 235 via an interface 240.By way of example but not limitation, processor 230 may be amicrocontroller and controlled device 235 may be a hard disk drivehaving a motor that is controlled according to signals provided by themicrocontroller. Controlled device 235 may also be external to targetsystem 210, for example an HVAC system or other device controlled byremote communication commands (e.g., commands via a communicationinput/output port, network interface, communication bus, etc.). Also, inthe event that there are multiple cores on processor 230, there may bemultiple implementations of debug controller 255 and debug monitor 256.For example, there may be a pair of debug controller 255 and debugmonitor 256 with each pair associated with an individual core to allowfor debugging of processes executing on that core. In this manner, itmay be possible to debug applications across the multiple cores orindividually on a single core.

In this example, processor 230 executes code stored in an associatedmemory 245 (which may be integrated within processor 230 and/or externalthereto) to perform predetermined functions. In general, embedded codeincludes at least two categories including: foreground, or real-timecode, and background, or non-real-time code. As is customary, processor230 has certain registers 250, including debug registers, associatedtherewith, which may also be either integral with the processor 230 orimplemented externally. As illustrated in this example, debug controller255 may interface with processor 230 via interface 260 to gain access(read only, or read/write as appropriate) to memory 245 and registers250 associated with processor 230. Interface 260 may be a bus within anIC when debug controller is internal to the IC containing processor 230or may be provided using an access port (sometimes referred to as anindirect access port). In this example, debug host 205 is alsoillustrated as communicatively coupled to target system 210 (and debugcontroller 255) via interface 265. Interface 265 may be used to providecommunication between debug host 205 and debug controller 255, forexample, to provide user commands and obtain query output from anapplication developer performing a debug session on target system 210.In one implementation, interface 265 may be based upon the JTAG standardmentioned above.

Turning to FIG. 3, state diagram 300 illustrates a basic operation ofreal-time mode debugging in accordance with one example. The EXE state305 in FIG. 3 represents normal code execution, e.g., processor 230 isexecuting code from memory 245. In the absence of any debug event, codeexecution continues as represented by reference numeral 310 in FIG. 3.

If however, there is a debug event, e.g., a breakpoint, as representedby state transition 315 in FIG. 3, this event causes the processor tosuspend code execution and enter code execution suspended (“SUSP”) state325. In accordance with state transition 320, the processor remains inSUSP state 325 for a period of time where no additional debug eventoccurs and no higher priority ISR needs to be serviced. On the otherhand, when a higher priority interrupt (e.g., real-time interrupt withassociated ISR) occurs while the processor is in SUSP state 325associated with the lower-priority code causing the original suspension,the processor may be caused to resume code execution as represented bystate transition 330. Once resumed, certain implementations ensure thatthe only code executed may be the ISR associated with the higherpriority interrupt and other code is not executed at this resumption ofprocessing. That is, in some implementations, resuming execution occursonly for ISRs that are a higher priority than the priority associatedwith a code portion for which the processor is currently in SUSP state325. Real-time code portions will almost always (if not always) beassociated with a higher priority than any non-real-time code portionsand different non-real-time code portions may have different relativepriorities.

With continued reference to FIG. 3, the act of transitioning from SUSPstate 325 to Interrupt during Debug Suspend (IDS) state 335, forexample, leaving SUSP state 325 due to an ISR of higher priority (e.g.,RT interrupt), may be logged by processor 230 or debug controller 255(depending on the implementation details). Also, at this statetransition, attributes reflecting the current processor context (e.g.,register and memory values) may be placed on a stack stored in memory245 or memory (not shown) internal to debug controller 255. The “currentprocessor context” that may be pushed on the stack may include anindication that the CPU resumed execution from a “halted” state. Thisindication may be useful to determine that code execution has returnedback to a location that was “awoken” by a higher priority processingtask. As used herein, the term “stack” is used and understood in acustomary sense with respect to software programming models.Accordingly, a stack refers to a mechanism (data construct) of storingdata entries in an ordered manner, such that entries may be added orremoved sequentially from the top or bottom. In some implementations,the stack used for storing context information may be implemented usinga standard functional/application stack to store the current executioncontext. Using the standard functional/application stack for debugcontext information may allow for standard behavior with respect to anISR that preempts the current task/thread.

In this example, the data entries of a stack may be the contents ofprocessor registers and/or locations in memory reflecting the currentoperational state of a processor with respect to an associated codeportion. Furthermore, as described above and as used herein, the term“context” shall be used to refer to a collection of information (flags,register values, control signal levels, memory contents, etc.) as itexists at a given point during operation of a processor as it executescode.

The context may be thought of as a state of the processor in conjunctionwith a code portion being subject to interrogation by a debuggerrelative to a SUSP state 325 of the processor. Preservation ofattributes for a processor context may allow for restoration of thatprocessor to the associated particular operational state. A “contextstack” or “debug stack” shall be understood herein to refer to a usuallyordered and sequential storage of context entries each reflecting theoperational state of a processor at an associated particular time (e.g.,specific breakpoint). Depending on the implementation, this may be adedicated stack or an existing stack that is augmented with additionalentries.

In the present example implementation, it is not required to make adistinction between halting in real-time code (transition 315) andhalting in non-real-time code (transition 330). Likewise, there is nodistinction between resuming code execution while halted in real-timecode (transition 340) and resuming code execution while halted innon-real-time code (transition 345). It is believed that suchdistinctions are not necessary because halting in real-time mode will bydefinition break the real-time nature of that particular real-timeprocess. However, because disclosed example implementations do notcompletely suspend the processor (e.g., execution continues for higherpriority interrupts) an improved, and more closely reflective ofreal-time, debugging session may be provided.

Managing Multiple Real-Time Debug Contexts

The addition of processor context to a stack storage mechanism inresponse to a debug event (e.g., correlated with state transition 330)may help to facilitate future halts (or other debug events) related toreturning from RT ISR IDS state 335 to SUSP state 325. This returntransition is represented by state transition 340 in FIG. 3. Forexample, when servicing of an RT ISR (or simply higher priorityinterrupt) in IDS state 335 completes, or when a new debug event isencountered, the processor may once again suspend code execution byreturning to SUSP state 325.

Having returned to SUSP state 325, the debug session with theapplication developer may be continued. In some cases, the applicationdeveloper may not even be aware of the transition to and back from IDSstate 335. Continuing with the debug session, the application developermay instruct (e.g., by a step, go, or, run command issued via the debughost) the processor to resume code execution. This may cause a return toEXE state 305 as represented by state transition 345 in FIG. 3 (assumingno further ISRs are pending). For example, this may occur as a result ofthe application developer requesting a “run” or “step” operation as partof an “asynchronous” debugger session. Asynchronous is used here toindicate that the timing of the debug session is relative to theperspective of the application developer interacting with a debug hostand may not be reflective of the timing of the processor. Thisperspective is, in part, because the processor has continued to servicehigher priority requests while the application developer's perception ofapplication run-time is suspended (e.g. perceived to be at SUSP state325) in the debug session.

One implication of the scenario depicted by the state diagram of FIG. 3is that when the processor is in SUSP state 325, accessing the debugcontext (i.e., internal registers, memory and so on) returns a truesnapshot; that is, in SUSP state 325, execution state changes and dataqueries (e.g., register and memory values) can be made against a knowncontext. On the other hand, when a processor is in IDS state 335, debugaccess can “confuse” the debugging tools and users, because entry intoand out of state 335 is asynchronous to user control or request.Execution state changes may cause misleading results to an applicationdeveloper's query of information in the system, because the values ofsystem resources may be dynamic. Accordingly, capabilities such as“rude” and “polite” information requests may be provided to assist theapplication developer in confidence of data returned. Rude and politeinformation requests with respect to maintaining a debug context inreal-time processors are presented in more detail below.

Coherent Debug View During Multi-Dimensional Debugging Operations

As will be apparent to those of ordinary skill in the art, having thebenefit of the present disclosure, real-time mode debugging introducescertain cases that can result in confusing results when interrogatingthe system. An executing interrupt service routine (ISR), such as an RTISR, will likely temporarily change some system resources such asregisters and memory. Reading these system resources while they are intheir temporary states does not provide a coherent view of the haltedstate of the system. Also, a user instructing the debug controller tochange the values of any resource that might be actively in use by areal-time interrupt service routine may result in undesirable systemoperation. This is in part, because the modification may occurasynchronously to the interrupt service routine flow and not reflect theintended action of the user requesting the change. To be clear, the userrequested the value to be changed for a certain context (i.e., contextof debug breakpoint) and not the running ISR. Accordingly, any requestto change resources may be delayed until a temporary context change hascompleted. That is, the system has completed the ISR and returned to theproper debug context at state 325. To address these issues, a real-timedebug system may be configured to provide the ability to ensure thatdebug accesses and execution requests are only applied when theprocessor is in a halted state (e.g., state 325). Such accesses arereferred to as “Polite” accesses.

FIG. 4a illustrates state diagram 400 and FIG. 4b illustrates a programflow diagram 402 which together depict how events may take place in adebugging session by allowing RT ISRs to execute while a CPU is haltedat a debug event. References to “polite” and “rude” access requests arealso explained relative to this program flow. The execution depicted inFIGS. 4a and 4b begins during a first period of program flow designatedT1 in FIG. 4b , during which the processor is in code execution state405 of FIG. 4a . In state 405, the processor is executing normally, asrepresented by block 410.

Following program flow interval T1, the processor is halted by a debugevent and enters a suspended state 415 of FIG. 4a , during which it ishalted, as reflected by block 420 in FIG. 4b , corresponding to programflow interval T2. In the depicted example, the overall duration of thishalted state at block 420 is designated T2 in FIG. 4b . Throughout thetime period corresponding to T2, “polite” debug accesses and executionrequests may be blocked for periods T3 and T4 because, as indicated byblocks 430 and 435, the processor is executing RT ISR 1 and RT ISR 2,respectively. Accordingly, “polite” requests may be serviced in theslices of time in T2 that occur before, in between, and after T3 and T4.In contrast, a “rude” request may be serviced at any time during T2 andmay return unexpected values if the access block is overridden by theuser using the rude request. Specifically, in time periods T3 and T4,there is no guarantee that the information returned to the user of arude request is accurate to the context associated with state 415 andblock 420 because further execution may have altered the values queriedor may inappropriately change a value in-use by an ISR. In general“rude” requests are serviced immediately at the potential peril orconfusion of the user and system. To summarize, a polite requestprovides information relative to the perceived context of the processorby not servicing it when not appropriate and a rude request is servicedwithout regard to correctness or context. Said another way, a politerequest made from the debugger relative to a halted context at block 420will only be serviced when the processor is in suspended state 415 andany requests made from block 420 that occur for the intervals where theprocessor is in state 425 (e.g., servicing either RT ISR #1 at T3 or RTISR #2 at T4) will be held or blocked as appropriate. For example, suchrequests may be held for a timeout period and, if not serviced withinthe time period, blocked so that control may be returned to the userwith an informative message. Upon the receipt of the informative messagethe user may choose to issue a rude request subject to therestrictions/conditions set forth herein with respect to rude requests.

Continuing with the example of FIGS. 4a and 4b , while the processor ishalted in suspended state 415 (block 420), a first real-time interruptservice request (RT ISR #1) is received. This transitions the processorto an interrupt service request RT ISR state 425 of FIG. 4a , duringwhich the processor executes the appropriate interrupt service routine,as reflected by block 430 in FIG. 4b . When the processor is in RT ISRstate 425, “Polite” debug accesses and execution requests (i.e., thoseassociated with block 420) are blocked or held till a proper time periodwhen neither RT ISR #1 or RT ISR #2 are executing. As shown in FIG. 4b ,the processor executes the appropriate ISR during a program flowinterval T3 that falls within a portion of interval T2. Upon completionof RT ISR #1, the processor returns to state 415.

The example of FIGS. 4a and 4b further depicts a second real-timeinterrupt service request (RT ISR #2), represented by block 435 in FIG.4b , with it being understood by those of ordinary skill that any numberof such RT ISRs could occur within the suspended interval T2. In thisexample, RT ISR #2 takes the processor once again from suspended state415 to RT ISR state 425. As shown, the processor remains in RT ISR mode425 throughout the servicing of the second RT ISR at block 435, duringprogram flow interval T4. In this example, RT ISR #1 and RT ISR #2 areshown to not have any overlap in duration, but that is only forsimplicity of explanation. The flow and transitions of FIGS. 4a-b couldresult in many levels of nested and overlapping interrupts depending onhow a system is configured and operating.

To complete the discussion of FIGS. 4a and 4b , upon completion of the“debug” event represented by block 420, the processor is allowed toreturn to normal code execution state 405 (represented in FIG. 4b byblock 440 and program flow interval T5). This completion may be theresult of a user instructing the breakpoint to be released, for example,by issuing a run, go, or step command. Normal flow can continue until anext debug event is detected at which point a debug controller may againinitiate a flow and state change progression as depicted in FIGS. 4a and4 b.

In the current example, the real-time debugging mode system provides atoggle that allows debug accesses and execution requests to bypass the“Polite” protections; these are sometime referred to as “Rude” accesses.Invoking such a bypass (user override) may be reserved for “user beware”situations such as trying to interact with a processor that has entered:a run-away condition while executing a real-time interrupt serviceroutine, an extended loop, or a condition waiting on some sort of devicetime-out, for example.

Managing Multiple Real-Time Debug Contexts

As briefly mentioned above, those of ordinary skill will also appreciatethat it is also possible to encounter a debug halt event while executinga real-time interrupt service routine, e.g., the ISR code may have asoftware breakpoint. Such halt events must be serviced. One consequenceof this need may be that the processor might be halted at multiplepoints—the original halt location and a subsequent halt location withinthe interrupt service routine (e.g., nested halts). Such a change in theactive halt location is referred to as a debug context change. Those ofordinary skill will appreciate that it is possible to have many debugcontexts stacked (or nested), because multiple real-time interruptservice requests may encounter debug halt events. The depth of thiscontext stack can change dynamically as more RT ISRs are encountered andhalted RT ISRs are resumed and execute to completion.

In order to stay synchronized with debug tools, a real-time debugenvironment (e.g., debug monitor 256 representing functionality of debugcontroller 255 and their interaction with debug host 205) preferablynotifies the tools any time the debug context changes. That is forexample, when a subsequent halt has been encountered, or an older haltis now at the top of the stack due to all higher level halts beingcleared. When this indication of context change is detected by the debugtools, the state of the new active context can be obtained and presentedto a user via the debug host, for example. This may be considered a“refresh” of the debug monitor with respect to exiting one context andentering the next applicable context.

In order to stay synchronized with debug tools, and with reference nowto FIGS. 5 and 6, an example of how a real-time debug environment andsystem may notify the tools any time the debug context changes isdescribed. FIGS. 5a and 5b illustrate, respectively, a flow diagram 500and a program flow diagram of real-time mode debugging in accordancewith one example. In FIG. 6, there is shown a signal timing diagramdepicting the real-time execution state, debug context and control, andCPU events associated with one possible real-time debugging session. Thesignal definitions for the timing diagram of FIG. 6 are as follows:

TABLE 1 RT_ISR When asserted, corresponds to the processor resumingexecution to service a real-time interrupt service request (RT ISR).Code Execution When asserted, processor execution has Suspendedsuspended. Code Execution When asserted, CPU is executing code. NEW_HALTSet Assertion indicates entry into a new debug context and causes aNEW_HALT flag to be set (e.g., a point in time for the debug monitor toestablish a new debug context, or take over one that has been setup bythe processor for the debug monitor to process). NEW_HALT ClearAssertion indicates that debugger (e.g., debug monitor and debugcontroller) has become aware of the new debug context and causes theNEW_HALT flag to be cleared (e.g., debug monitor has completed acollection of or, a creation of a new debug context). Debug RUNAssertion indicates a debugger-initiated RUN Canceled request has beencanceled. Debug RUN Assertion indicates that the debugger has Requestsubmitted a RUN request. RT Interrupt Assertion indicates that aninterrupt designated as real-time has been acknowledged. RT InterruptReturn Assertion indicates a return from an interrupt that wasdesignated as real-time at the time it was acknowledged. Debug EventAssertion indicates a request to halt the processor, e.g., for abreakpoint, a return from an RT ISR, or a user halt request.

In FIGS. 5a, 5b , and 6, an example execution sequence is shown invarious forms beginning with a Code Execution phase 510 (FIG. 5a ) inwhich the processor 230 is executing normally, as represented by block505 in FIG. 5b . During this time, which precedes time T6 indicated inFIGS. 5a, 5b , and 6, the fact that the processor 230 is in a codeexecution state 510 (FIG. 5a ), is reflected by the asserted level ofthe Code Execution signal in FIG. 6.

As in the previous exemplary scenario of FIGS. 4a and 4b , at time T6 inthe scenario of FIGS. 5a, 5b , and 6 the processor 230 is halted by adebug event, as represented by block 515 in FIG. 5b . This event isreflected by assertion at time T6 of the Debug Event signal shown inFIG. 6. The debug event also causes assertion of the NEW_HALT Setsignal, thereby setting a NEW_HALT flag, implemented as a memory orregister location within the target system 210. At the same time (T6),the Code Execution Suspended signal is asserted, and the Code Executionsignal is de-asserted, as shown in FIG. 6. At time T6, the processorstate transitions (reference numeral 520) from Code Execution state 510to Suspended state 525.

Following time T6, after the processor has been halted due to a debugevent, a real-time interrupt service request (RT ISR #1, block 530 inFIG. 5b ) occurs, at the time designated T7 in FIGS. 5a, 5b , and 6. TheRT ISR #1 is initiated with assertion of the RT Interrupt signal, shownat time T7 in FIG. 6. RT ISR #1 occurring at time T7 causes a processorstate transition (reference numeral 535 in FIG. 5a ) from suspendedstate 525 to a RT ISR service state 540. As shown in FIG. 6, occurrenceof RT ISR #1 at time T7 causes the Code Execution Suspended signal tode-assert and the RT ISR signal to assert, thereby enabling theprocessor to service the RT ISR.

The NEW_HALT (clear) signal is asserted at time T8 (FIG. 6 only),causing a reset of the NEW_HALT flag and reflecting that the NEW_HALTflag, set at time T6 by assertion of the NEW_HALT set signal, has beenread by the debug controller 255. Note that T8 is not shown in FIGS. 5aof 5 b, because the occurrence of the context stack being read by thedebug controller 255 is an event not related in time to any state changeevent shown in FIG. 5a or 5 b.

In the example of FIGS. 5a, 5b , and 6, a next event to occur is afurther debug event (block 545 in FIG. 5b ) commencing with assertion ofthe Debug Event signal at time T9. The debug event at time T9 leads toassertion of the NEW_HALT (set) signal, assertion of the Code ExecutionSuspended signal, and de-assertion of the RT ISR signal, as shown inFIG. 6. Thus, at time T9, processor 230 goes through state transition550 from RT ISR state 540 to another Code Execution Suspended state 555,this time the suspension occurring during an execution of a real-timeinterrupt service routine as shown at block 530 (RT ISR #1). Because thedebug event at time T9 occurs during servicing of RT ISR #1, the debugevent at time T9 again causes assertion of the NEW_HALT (set) signal,assertion of the Code Execution Suspended signal (hence the transition550 to state 555 in FIG. 5a ), and de-assertion of the RT ISR signal(see FIG. 6).

At time T10, the NEW_HALT (clear) signal is asserted, causing a reset ofthe NEW_HALT flag and reflecting that the NEW_HALT flag, set at time T9by assertion of the NEW_HALT set signal, has been read by the debugcontroller 255.

In accordance with one aspect of the present example, in the periodbetween times T9 and T10 in FIG. 6, it can be seen that the Debug RunRequest signal is asserted, followed immediately by the Debug RunCanceled signal. This reflects an example situation wherein the RUNrequest fails or is denied due to the NEW_HALT flag having been set attime T9 and not reset prior to the Debug Run Request being issued.

With continued reference to the illustrative example of FIGS. 5a, 5b ,and 6, the next event shown to occur is another real-time interruptservice request, RT ISR #2, occurring at time T11 and represented byblock 560 in FIG. 5b . With the occurrence of RT ISR #2, the processortransitions from Code Execution Suspended state 555 to a real-timeinterrupt service routine (RT ISR) state 565, as represented by statetransition 570 in FIG. 5a . This, in turn, leads to assertion of the RTISR signal (FIG. 6), such that the real-time interrupt can be serviced,as well as de-assertion of the Code Execution Suspended signal,reflecting transition 570 from state 555 to state 565.

In the example of FIGS. 5a, 5b , and 6, it is shown that the processingof RT ISR #2 concludes prior to time T12, as reflected in the assertionof the RT Interrupt Return signal. Thus, at time T12, the RT ISR signalis de-asserted, and the Code Execution Suspended signal is reasserted,reflecting the transition 575 of the processor state from RT ISR state565 back to Code Execution Suspended state 555. Thus, the processor isat Code Execution Suspended state 555.

A next event depicted in the example of FIGS. 5a, 5b , and 6 is a thirdreal-time interrupt service request (RT ISR #3) as indicated by block580 in FIG. 5b . The RT Interrupt signal reflecting RT ISR #3 isasserted at time T13. This leads to the transition 570 (for a secondtime) of the processor from Code Execution Suspended state 555 back intoRT ISR state 565.

As shown in FIGS. 5a, 5b , and 6, the processing of RT ISR #3 concludesslightly before time T14, as reflected in the assertion of the RTInterrupt Return signal. Thus, at time T14 (the trailing end ofassertion of the RT Interrupt Return signal, the RT ISR signal isde-asserted, and the Code Execution Suspended signal is reasserted,reflecting transition 575 (for a second time) of the processor statefrom RT ISR state 565 back to Code Execution Suspended state 555. Thus,the processor is at Code Execution Suspended state 555.

Continuing with FIGS. 5a, 5b , and 6, the processor remains in CodeExecution Suspended state 555 from time T14 until a user request toresume execution (assertion of the Debug RUN Request signal as shown attime T15 in FIG. 6). This is also shown by the leading edge of assertionof the Debug RUN Request signal starting at time T15 that causes thetransition 585 of the processor state from Code Execution Suspendedstate 555 to a Code Execution state 590. This same period is alsoreflected by block 595 in FIG. 5 b.

At time T16 in FIG. 6, there is an assertion of NEW_HALT (set) signal.In this instance, NEW_HALT is set to indicate the return from RT ISR #1while the CPU is still halted (i.e., as shown with block 515 in FIG. 5b). This return from RT ISR #1 is reflected in a transition fromExecution state 590 to Code Execution Suspend 525 (that was previously ahalt position) and returns to the context that was set based on theoriginal debug event occurring at time T6. That is, NEW_HALT is setbecause we are returning from an RT ISR that itself created a new debugcontext. Thus, a context change is required to prepare the debug context(i.e., return it to what it was) for a user interaction in block 515 ofFIG. 5b . This can also be thought of as popping the stack containingthe debug context to retrieve the next applicable debug context.

The NEW_HALT (clear) signal is asserted at time T17 (only shown in FIG.6), causing a reset of the NEW_HALT flag and reflecting that theNEW_HALT flag, set at time T16 by assertion of the NEW_HALT set signal,has been read by the debugging software (i.e., debug monitor). That is,the assertion of the NEW_HALT (clear) signal reflects the fact that thedebug monitor is aware of and acknowledged that it must retrieve (or hasretrieved) the context information from the stack containing thecontext.

As shown in FIG. 6, at time T18, a Debug RUN Request is issued/asserted,such that the processor transitions from Code Execution Suspended state525 to Code Execution state 510, as represented by transition 597 inFIG. 5a . At this time, the processor resumes normal execution, asrepresented by block 598 in FIG. 5 b.

Recapping, in FIGS. 5a and 5b , a scenario is illustrated in which adebug halt event is encountered while the processor is servicing areal-time interrupt service request (RT ISR) after already havingreached a debug event. In FIG. 5b , this occurs at time T9, when a debughalt is initiated due to assertion of Debug Event signal (see FIG. 6) asrepresented by block 545 in FIG. 5b . Such a halt event must be servicedand causes creation of a new debug context (and a corresponding push tothe stack storing the debug context). An artifact of this is that theprocessor and debug monitor are now concerned with halts at multiplepoints—the original halt location (time T6) and a subsequent haltlocation (time T9), which occurs during servicing of RT ISR #1 (blocks530 plus 595). This change in active halt location is referred to as adebug context change. In fact, it is possible to have many debugcontexts stacked, because multiple RT ISRs may encounter debug haltevents. The depth of this stack of debug contexts changes dynamically asmore RT ISRs halt and halted ones are resumed and execute to completion.

In order to present a coherent debug environment (e.g., debug monitor256 working in coordination with a debug controller 255 and debug host205), the real-time debug mode (RM) for the debug system of the presentexample may notify supporting debug tools any time the debug contextchanges. That is, for example, a different debug halt event has beenencountered, or an older halt is now represented by an active stackentry due to all higher-level halts being cleared. See, for example,times T9 (representing a debug halt encounter) and T16 (representing areturn to a previous debug halt location) in FIGS. 5a and 5b . When thisindication is detected by or provided to the debug tools, the state andinformation with respect to the newly active context (which may be areturn to an old context) can be presented to the user, for example, bypresenting information on a user-interface associated with debug host205.

In the illustrative system, debug events that halt processor operation(e.g., breakpoints, triggers, watch points, or other user commands)cause execution to suspend. When the processor is halted, debug eventsthat resume operation (e.g., triggers, user commands) cause execution toresume. A real-time interrupt service request (RT ISR), i.e., any ISRthat must be serviced while the processor is halted by a debug event,will cause the halted processor to run (but not necessarily in a codeexecution state). Once the processor resumes from a halted state tobegin servicing a RT ISR, if no breakpoints are encountered whileservicing that RT ISR, then no new debug contexts will be created.Accordingly, execution of RT ISRs with no breakpoints may not bepresented or apparent to the user.

Some functional characteristics for the RM system of the present exampleare summarized as follows:

A register bit field (EXMODE) may be provided to configure the debugcontroller 255 for real-time debugging mode operation (e.g., RMfunctionality). Debug events that halt operations (breakpoints,triggers, user commands) may cause execution to suspend. When halted,Debug Events that resume operation (triggers, user commands) typicallycause execution to resume.

An RT ISR may be thought of as any ISR that is being serviced while theprocessor is halted by a debug event. When the processor is executingnormally (no thread/task/ISR is under debug halt), then none of theinterrupts in the system are required to be considered RT ISRs. Whenoperating in real-time debug mode (e.g., executing RM functionality),any interrupt designated as an RT ISR (or higher priority than codeassociated with the current debug context) will cause a halted processorto resume. The method for designating RT interrupts may beimplementation-specific, as would be apparent to those of ordinary skillin the art having the benefit of the present disclosure.

When operating in RM, other interrupt masks for RT interrupts may beignored when halted, and the resume boundary may be the firstinstruction of the highest priority RT interrupt that is currentlyflagged as pending. Once a processor resumes from being halted to beginservicing an RT interrupt, normal interrupt masking and priority may behonored until all outstanding interrupt requests are serviced and theprocessor returns to the debug halted state.

A flag (NEW_HALT) may be used to indicate that a new debug context isactive. That is, we have entered a new debug context for the first timeor we have returned to a previous context by completing execution of acode portion associated with a context immediately subsequent to thecontext for which we are returning. In this manner, NEW_HALT is assertedby processor hardware when the debug context changes (i.e., one is addedor one is cleared from the stack containing the debug context). WhenNEW_HALT is asserted, a new debug context may be pushed onto the stackcontaining the debug context. Alternatively, NEW_HALT could be assertedto indicate that the halt at the current stack pointer has been clearedand the halt associated with the next context on the stack is now active(e.g., a pop of the stack). The NEW_HALT flag is de-asserted upon thedebug monitor completing its manipulation of the stack with respect tothe debug context change.

If a new debug context is active before the processor is able to act onthe debug command, the debug request is canceled. A flag CANCEL_EXE maybe used to indicate that a debug request has been canceled. If a newdebug context is active before the processor is able to act on anindirect access port request, the indirect access port request may becanceled. A flag CANCEL_IAP may be used to indicate than an access portinterface request has been canceled.

A flag MEM_IGNORE_CTXT may be used to direct a debug monitor as to howthe indirect access port is coordinated with the processor regardingdata request accesses (e.g., memory, CPU register, etc.) and theexecution of RT interrupts. When de-asserted with the default statereflecting a “Polite” request, all debug data access requests are heldpending while any underlying RT ISR is executing. That is, the accessrequest may wait until the underlying code returns to the current haltedstate and all information should be accurate with respect to the currentdebug context. Any pending debug request is canceled (by hardware) whenthe debug context changes (i.e., a new context is active presumably at adifferent halt location with respect to code execution).

Distinguishing from “Polite” requests, when the MEM_IGNORE_CTXT isasserted the debug monitor is informed to make a “Rude” request. For arude request, all debug access requests (e.g., register or memoryvalues) are initiated regardless of the execution state of theprocessor. Any system inconsistencies or errors that might result from acollision between a debug access and the state of an executing RT ISRshould be considered by the user before requesting an access thatignores the RT state. “Rude” requests may be desirable, for example,when a “Polite” request is not serviced within a certain amount of time(i.e., experiences a time-out). As mentioned above, users must beconsiderate of the fact that rude requests may not return informationaccurate with respect to the current debug context.

Referring to FIG. 7, there is shown a flow diagram 700 illustratingoperation within a debugging environment in accordance with thisdisclosure. Flow diagram 700 begins from the perspective of the user 215interacting with a processor equipped with capabilities in accordancewith one or more disclosed examples. As shown in FIG. 7, it is customaryfor the purposes of debugging for a user 215 to establish one or moredebugging events such as breakpoints within the software/firmware beingdebugged, as represented in FIG. 7 by block 705. Thereafter, user 215initiates a debugging session by allowing the system to execute thesoftware (or firmware), as represented by block 710.

Execution of the software places the processor (CPU) in a running state,as represented by block 715. In the course of execution, the CPU must beresponsive to certain events, including the above-noted breakpointsestablished by user 215, as well as real-time interrupt service requests(RT ISRs). Block 720 represents the CPU's recognition of the occurrenceof an interrupt representing a breakpoint encountered in the code beingexecuted and the CPU halts execution.

Upon halting at block 720, it is determined what type of breakpoint theCPU has been halted at. In this example, there are three possibleoptions as indicated by decision 725. A first option from decision 725is a “New” breakpoint. In this example, a new breakpoint represents abreakpoint that the CPU has not previously been halted at for this debugsession. In the case of a new breakpoint, flow continues to block 735where a current context (if any) is stored and a new context, which willbecome the current context, is created. In this flow path, the NEW_HALTflag will be set to indicate to the debug monitor that context changingis taking place. Note, this is the flow path that an initial (i.e., afirst) interrupt of a debug session will take to create the initialcontext. Once the context has been established, flow continues to block745 where the current context is made available to the user 215 (and theNEW_HALT flag is unset).

A second option from decision 725 is a “Previous” breakpoint. In thisexample, a previous breakpoint represents a breakpoint that has beenpreviously encountered during this debug session. Accordingly, there haspreviously been setup a context for this breakpoint. As indicated atblock 730, the debug monitor may restore the previous context as thecurrent context and make the now current context (i.e., the previous onefrom this breakpoint) available to the user 215. In this flow path, theNEW_HALT flag will be set to indicate to the debug monitor that contextchanging is taking place. Note, this is the flow path that returningfrom a lower level (e.g., higher priority code) breakpoint that hadpre-empted a previously established breakpoint would follow. Once thecontext has been restored, flow continues to block 745 where the currentcontext is made available to the user 215 (and the NEW_HALT flag isunset).

The third and final option from decision 725 in this example flow is a“Current” breakpoint. In this example, a current breakpoint represents abreakpoint that is still active but has been pre-empted from higherpriority code (e.g., an RT ISR) while in a debug session (see block760). Accordingly, the current context already matches this breakpointand the NEW_HALT flag does not indicate that a context change must takeplace. Flow returns to block 745 to “continue” to make the currentcontext available to user 215. Note, this is the flow path thatreturning from a lower level (e.g., higher priority code) that did notencounter any breakpoint but had pre-empted the halt of the “active”breakpoint would follow. That is, the higher priority code (e.g., an RTISR) has caused the CPU to awaken and execute it (block 715) and thenreturned to the interactive debug state (blocks 745 and 750). Thispre-emption is shown by the flow path through block 760. Note, thatrunning a “single step” run command (or similar) would follow througheither the new context path of block 735 in a case where the return ofthe limited run command resulted in a new breakpoint or would followthrough the previous context path of block 730 if, in a limited set ofcircumstances, the return point of the limited run command happened tocoincide with a point for which a previous context had already beencreated.

In all cases, after the current context is made available to user 215,the debug session enters an “interactive” phase as shown by block 750.Assuming no pre-emption takes place the CPU remains halted and the usermay enter debug access requests (block 755) or debug run requests (block765). If the user enters a debug access request (block 755), adetermination is made as to whether or not higher priority code iscurrently executing as shown by decision 770. If no higher priority codeis executing, flow continues to block 790 where the request will beserviced and respect the current context. However, if higher prioritycode is currently executing (the YES prong of decision 770), flowcontinues to block 775 where the type of request, e.g., rude or polite,the user has made is determined. If the request is rude, the flowcontinues to block 780 where the request is immediately serviced withoutrespecting the current context. If the request is polite, then flowcontinues to block 785 where the request will be held for a period oftime to wait for the higher priority code to complete prior tocontinuing to block 790 where the request can be serviced and honor thecurrent context. As explained above, if the current context is nothonored for the data access request, the user may be presented withinformation that is not consistent with the breakpoint they believe theyare sitting at.

Returning to the discussion of the interactive session (block 750), thesecond type of request a user may make is a debug run request. This maybe a) a step request asking the debugger to move forward in the“current” code by one step, or b) a “limited” run command that tells thedebugger an amount of code to run (e.g., run X steps, run till Yaddress, etc.), or c) may be a simple “go” or “run” command to indicatethat the breakpoint may be exited. In any of these cases, the CPU isallowed to execute (block 715) for the specified period of time and thenreturn, if necessary, to the current breakpoint context (of course atthe new run-time address). In the case, that no other breakpoints areencountered, flow will return to the interactive debug session block 750through the path of a “current” breakpoint type at decision 725.

As shown in FIG. 7, so long as a debug run request is not issued, block750 continues to be the “apparent” CPU system state from the perspectiveof the user 215, during which time the CPU can be responsive to RT ISRs(block 760) and user 215 can make data access requests. When user 215does issue a debug run request following a breakpoint, this is reflectedby the path from block 765 to block 715.

Referring now to FIG. 8, a general purpose processor is illustrated(without all possible elements of this disclosure) including a debugcontroller 806 and a debug monitor in accordance with one or moredisclosed example implementations. FIG. 8 illustrates a high-level blockdiagram of a computing device 800 (computing system) that may be used toimplement one or more disclosed examples (e.g., an embedded processor aspart of an embedded real-time system control device, a processorconfigured with an application to perform a debug session, etc.). Forexample, computing device 800, illustrated in FIG. 8, could represent aclient device or a physical server device and could include eitherhardware or virtual processor(s) depending on the level of abstractionof the computing device. In some instances (without abstraction)computing device 800 and its elements as shown in FIG. 8 each relate tophysical hardware and in some instances one, more, or all of theelements could be implemented using emulators or virtual machines aslevels of abstraction. In any case, no matter how many levels ofabstraction away from the physical hardware, computing device 800 at itslowest level may be implemented on physical hardware. As also shown inFIG. 8, computing device 800 may include one or more input devices 830,such as a keyboard, mouse, touchpad, or sensor readout (e.g., biometricscanner), communications port(s), and one or more output devices 815,such as displays, communication ports, speakers for audio, or printers.Some devices may be configured as input/output devices also (e.g., anetwork interface, communications port, or touchscreen display).Computing device 800 may also include communications interfaces 825,such as a network communication unit that could include a wiredcommunication component and/or a wireless communications component,which may be communicatively coupled to processor 805. The networkcommunication unit may utilize any of a variety of proprietary orstandardized network protocols, such as Ethernet, TCP/IP, to name a fewof many protocols, to effect communications between devices. Networkcommunication units may also comprise one or more transceivers thatutilize the Ethernet, power line communication (PLC), Wi-Fi, cellular,and/or other communication methods.

As illustrated in FIG. 8, computing device 800 includes a processingelement, such as processor 805, that contains one or more hardwareprocessors, where each hardware processor may have a single or multipleprocessor cores. Computing device 800 may include a debug controller 806that may be configured to execute a debug monitor (e.g., as illustratedas element 256 of FIG. 2) according to one or more disclosedimplementation. Debug controller 806 may be implemented as part of thesame IC as processor 805 or may be on a separate but communicativelycoupled IC.

In one example, the processor 805 may include at least one shared cachethat stores data (e.g., computing instructions) that are utilized by oneor more other components of processor 805. For example, the shared cachemay be a locally cached data stored in a memory for faster access bycomponents of the processing elements that make up processor 805. Insome cases, the shared cache may include one or more mid-level caches,such as level 8 (L2), level 3 (L3), level 4 (L4), or other levels ofcache, a last level cache (LLC), or combinations thereof. Examples ofprocessors include, but are not limited to a central processing unit(CPU) microprocessor. Although not illustrated in FIG. 8, the processingelements that make up processor 805 may also include one or more othertypes of hardware processing components, such as graphics processingunits (GPUs), application specific integrated circuits (ASICs),field-programmable gate arrays (FPGAs), and/or digital signal processors(DSPs).

FIG. 8 illustrates that memory 810 may be operatively andcommunicatively coupled to processor 805. Memory 810 may be anon-transitory medium configured to store various types of data. Forexample, memory 810 may include one or more storage devices 820 thatcomprise a non-volatile storage device and/or volatile memory. Volatilememory, such as random access memory (RAM), can be any suitablenon-permanent storage device. The non-volatile storage devices 820 caninclude one or more disk drives, optical drives, solid-state drives(SSDs), tap drives, flash memory, read-only memory (ROM), and/or anyother type memory designed to maintain data for a duration time after apower loss or shut down operation. In certain instances, thenon-volatile storage devices 820 may be used to store overflow data ifallocated RAM is not large enough to hold all working data. Thenon-volatile storage devices 820 may also be used to store programs thatare loaded into the RAM when such programs are selected for execution.

Persons of ordinary skill in the art are aware that software programsmay be developed, encoded, and compiled in a variety of computinglanguages for a variety of software platforms and/or operating systemsand subsequently loaded and executed by processor 805. In one instance,the compiling process of the software program may transform program codewritten in a programming language to another computer language such thatthe processor 805 is able to execute the programming code. For example,the compiling process of the software program may generate an executableprogram that provides encoded instructions (e.g., machine codeinstructions) for processor 805 to accomplish specific, non-generic,particular computing functions.

After the compiling process, the encoded instructions may then be loadedas computer executable instructions or process steps to processor 805from storage 820, from memory 810, and/or embedded within processor 805(e.g., via a cache or on-board ROM). Processor 805 may be configured toexecute the stored instructions or process steps in order to performinstructions or process steps to transform the computing device into anon-generic, particular, specially programmed machine or apparatus.Stored data, e.g., data stored by a storage device 820, may be accessedby processor 805 during the execution of computer executableinstructions or process steps to instruct one or more components withinthe computing device 800.

A user interface (e.g., output devices 815 and input devices 830) caninclude a display, positional input device (such as a mouse, touchpad,touchscreen, or the like), keyboard, or other forms of user input andoutput devices. The user interface components may be communicativelycoupled to processor 805. When the output device is or includes adisplay, the display can be implemented in various ways, including by aliquid crystal display (LCD) or a cathode-ray tube (CRT) or lightemitting diode (LED) display, such as an organic light emitting diode(OLED) display. Persons of ordinary skill in the art are aware that thecomputing device 800 may comprise other components well known in theart, such as sensors, powers sources, and/or analog-to-digitalconverters, not explicitly shown in FIG. 8.

Certain terms have been used throughout this description and in theclaims to refer to particular system components. As one skilled in theart will appreciate, different parties may refer to a component bydifferent names. This document does not intend to distinguish betweencomponents that differ in name but not function. In this disclosure andclaims, the terms “including” and “comprising” are used in an open-endedfashion, and thus should be interpreted to mean “including, but notlimited to . . . .” Also, the term “couple” or “couples” is intended tomean either an indirect or direct wired or wireless connection. Thus, ifa first device couples to a second device, that connection may bethrough a direct connection or through an indirect connection via otherdevices and connections. The recitation “based on” is intended to mean“based at least in part on.” Therefore, if X is based on Y, X may be afunction of Y and any number of other factors. The terms configured andconfigurable are closely related. In the context of this disclosure, theterm configured may be used to indicate that an item may be preset tooperate in a default manner but does not necessarily mean that the itemmay not be changed and “re-configured” during operation. The term“configurable” may be used to specifically indicate that an item may notbe pre-set with any particular default condition but is likely (but notrequired) to change at run-time, during operation, or at some point inits existence.

The above discussion is meant to be illustrative of the principles andvarious implementations of the present disclosure. Numerous variationsand modifications will become apparent to those skilled in the art oncethe above disclosure is fully appreciated. It is intended that thefollowing claims be interpreted to embrace all such variations andmodifications.

What is claimed is:
 1. A computing device comprising: a processing unit;and a debug controller communicatively coupled to the processing unitand including an input/output interface, wherein the debug controllercontains logic that causes the debug controller to perform a debugmonitor function, the debug monitor function configured to: in responseto a first debug event associated with a first code section having afirst execution priority, pause the processing unit and establish afirst debug context; receive an indication that a second code section ofa higher execution priority than the first execution priority requiresservicing while the processing unit is paused at the first debug event;allow the processing unit to resume execution to service the second codesection while maintaining the first debug context, wherein at least oneinformation access request received via the input/output interface ofthe debug controller is held while executing the second code section;and return to an execution state consistent with the first debugcontext, in part, by pausing the processing unit in the first codesection upon completion of servicing the second code section.
 2. Thecomputing device of claim 1, wherein: the first debug event includes oneof a breakpoint in the first code section, a trigger received at theinput/output interface, a user command received at the input/outputinterface, and a watch-point in the first code section.
 3. The computingdevice of claim 1, wherein: the indication that the second code sectionis the higher execution priority than the first execution priority isreceived via the input/output interface.
 4. The computing device ofclaim 1, wherein: the debug monitor function is further configured toset a flag upon completion of servicing the second code section.
 5. Thecomputing device of claim 1, wherein: the at least one informationaccess request received via the input/output interface of the debugcontroller is serviced before servicing the second code section.
 6. Thecomputing device of claim 1, wherein: the at least one informationaccess request received via the input/output interface of the debugcontroller is serviced after completion of servicing the second codesection.
 7. The computing device of claim 1, wherein: the input/outputinterface includes at least one of a keyboard, a mouse, a touchpad, abiometric scanner, an input communication port, a display, an audiospeaker, a printer, and an output communication port.
 8. The computingdevice of claim 1, wherein: the debug controller is configured forreal-time debugging.
 9. The computing device of claim 8, wherein: aregister bit field configures the debug controller for real-timedebugging.
 10. The computing device of claim 1, wherein: the processingunit includes a plurality of cores, wherein each of the plurality ofcores is coupled to an instance of the debug monitor function.
 11. Amethod comprising: receiving, at an input/output interface of a debugcontroller coupled to a processor, a user command to halt the processorexecuting a first code section having a first priority; in response tothe user command: establishing, by the debug controller, a first debugcontext for the first code section; and halting, by the debugcontroller, execution of the first code section by the processor at apoint in the first code section; while the processor is halted,receiving, by the debug controller, an indication associated with asecond code section of a higher execution priority than the first codesection that the second code section requires servicing; in response tothe indication associated with the second code section: resuming, by thedebug controller, execution by the processor of the second code section,wherein at least one information access request is held while executingthe second code section; and upon completion of execution of the secondcode section: returning, by the debug controller, to the first debugcontext; and halting, by the debug controller, execution of theprocessor at the point in the first code section.
 12. The method ofclaim 11, wherein: the at least one information access request isserviced during the servicing of the second code section.
 13. The methodof claim 11, further comprising: the at least one information accessrequests is serviced before or after the servicing of the second codesection.
 14. The method of claim 11, wherein: the processor includes aplurality of cores.
 15. The method of claim 14, wherein: each one of theplurality of cores is coupled to a respective one of a plurality ofdebug monitors.
 16. The method of claim 11, further comprising: thesecond code section having a breakpoint; upon the processor reaching thebreakpoint: establishing, by the debug controller, a second debugcontext for the breakpoint; and halting, by the debug controller,execution of the processor at the breakpoint; while the processor ishalted at the breakpoint, receiving, by the debug controller, anindication associated with a third code section of a higher executionpriority than the second code section that the third code sectionrequires servicing; in response to the indication associated with thethird code section: resuming, by the debug controller, execution by theprocessor of the third code section, wherein at least two informationaccess requests are held while executing the third code section; andupon completion of execution of the third code section: returning, bythe debug controller, to the second debug context; and halting, by thedebug controller, execution of the processor at the breakpoint.
 17. Themethod of claim 16, further comprising: receiving, by the debugcontroller at the input/output interface, a first resume command toresume the processor executing the second code section; executing, bythe debug controller, the first resume command to resume execution ofthe processor at the breakpoint; receiving, by the debug controller atthe input/output interface, a second resume command to resume theprocessor executing the first code section; and executing, by the debugcontroller, the second resume command to resume execution of theprocessor at the point in the first code section.
 18. The method ofclaim 16, further comprising: setting, by the debug controller, a firstflag in response to establishing the first debug context; and setting,by the debug controller, a second flag in response to establishing thesecond debug context.
 19. A method comprising: executing, by aprocessing unit, a first code section having a first execution priority;pausing, by the processing unit, in response to a first debug eventassociated with the first code section; in response to pausing inresponse to the first debug event, retrieving, by the processing unit, afirst debug context; receiving, by the processing unit, an indicationthat a second code section of a higher execution priority than the firstexecution priority requires servicing while the processing unit ispaused at the first debug event; in response to a second debug event,resuming, by the processing unit, execution to service the second codesection while maintaining the first debug context, wherein at least oneinformation access request is held while executing the second codesection; and pausing the processing unit in the first code section uponcompletion of servicing the second code section to return to anexecution state consistent with the first debug context.
 20. The methodof claim 19, wherein: the first debug event includes one of a breakpointin the first code section, a trigger received at an input/outputinterface, a user command received at the input/output interface, and awatch-point in the first code section.